<template>
  <div class="home-banner">
    <!-- 使用轮播图组件 -->
    <xtx-carousel :duration="2000" autoplay :sliders="sliders"></xtx-carousel>
  </div>
</template>
<script setup>
import { findBanner } from '@/api/home'
import { ref } from 'vue'

// 获取banner轮播图数据
const sliders = ref(null)
findBanner().then(({ result }) => {
  sliders.value = result.map(item => {
    return {
      id: item.id,
      imgUrl: item.imgUrl,
      hrefUrl: item.hrefUrl.replace('category', 'cate')
    }
  })
})
</script>
<style scoped lang="less">
.home-banner {
  width: 1240px;
  height: 500px;
  position: absolute;
  left: 0;
  top: 0;
  z-index: 98;

  // 轮播图样式定制：穿透
  .xtx-carousel {
    :deep(.carousel-btn.prev) {
      left: 270px;
    }

    :deep(.carousel-indicator) {
      padding-left: 250px;
    }
  }
}
</style>